﻿/**
 * NumberUtils Static Math Sub Class - Created by FlashFrameLess Team OCT/2008
 *
 * @author		FabioTNT / FlashFrameLessTeam - http://www.flashframeless.com/
 * @version		1.0
 */

package com.flashframeless.math {
	
	public class NumberUtils {
		
		public function NumberUtils():void {
			
			trace( "NumberUtils is a static class and shouldn't be instantiated." );
			
		}
		
		/**
		 * Set target value, recive parameter by Item handler.
		 *
		 * @param	status	Boolean
		 * @return			Number
		 */
		public static function setToRange( number:Number, min:Number, max:Number, auxMethod:String = '' ) : Number {
			
			number = Math.min( number, max );
			number = Math.max( number, min );
			
			return auxMethod != '' ? Math[auxMethod]( number ) : number;
			
		}
		
		/**
		 * Correct Zero.
		 *
		 * @param	number	uint
		 * @return			String
		 */
		public static function correctZero( number:uint ) : String {
			
			var fixedNumber:String = String( number );
			
			if ( fixedNumber.length == 1 ) {
				
				fixedNumber = '0' + fixedNumber;
				
			}
			
			return fixedNumber;
			
		}
		
	}
}